/*
 * DIM-SUM操作系统 -- 位查找实现文件
 *
 * Copyright (C) 2022 国科础石(重庆)软件有限公司
 *
 * 作者: Jiayuan Liang <liangjiayuan@kernelsoft.com>
 *
 * License terms: GNU General Public License (GPL) version 3
 *
 */

#include <dim-sum/bitops.h>
/* #include <dim-sum/module.h> */
#include <asm/types.h>
#include <asm/byteorder.h>
#include <dim-sum/bitmap.h>

#ifndef find_last_bit
unsigned long find_last_bit(const unsigned long *addr, unsigned long size)
{
		if (size) {
				unsigned long val = BITMAP_LAST_WORD_MASK(size);
				unsigned long idx = (size-1) / BITS_PER_LONG;

		do {
			val &= addr[idx];
			if (val)
				return idx * BITS_PER_LONG + __fls(val);

		val = ~0ul;
				} while (idx--);
		}
		return size;
}
/**
 * EXPORT_SYMBOL(find_last_bit);
 */
#endif

